package cn.tedu.boyou.mgrsite.controller;

import cn.tedu.boyou.acticle.domain.StrategyTag;
import cn.tedu.boyou.acticle.service.IStrategyTagService;
import cn.tedu.boyou.acticle.service.IStrategyService;
import cn.tedu.boyou.common.query.StrategyTagQuery;
import cn.tedu.boyou.common.util.AjaxResult;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/strategyTag")
public class StrategyTagController {

    @Reference
    private IStrategyTagService strategyTagService;
    @Reference
    private IStrategyService strategyService;

    @Value("${file.path}")
    private String filePath;

    @RequestMapping("/list")
    public String list(Model model, @ModelAttribute("qo")StrategyTagQuery qo){
        model.addAttribute("pageInfo",strategyTagService.query(qo));
        model.addAttribute("strategies",strategyService.listAll());
        return "strategyTag/list";
    }

    @RequestMapping("/saveOrUpdate")
    @ResponseBody
    public Object saveOrUpdate(StrategyTag strategyTag){
        strategyTagService.saveOrUpdate(strategyTag);
        return new AjaxResult();
    }
    @RequestMapping("/delete")
    @ResponseBody
    public Object delete(Long id){
        strategyTagService.delete(id);
        return new AjaxResult();
    }


}
